Skip to content

[MOOSE-350] Faceted (FacetWP) Directory#327

Open
GeoffDusome wants to merge 6 commits intotask/MOOSE-350/add-facetwp-pluginfrom
feature/MOOSE-350/faceted-directory
Open

[MOOSE-350] Faceted (FacetWP) Directory#327
GeoffDusome wants to merge 6 commits intotask/MOOSE-350/add-facetwp-pluginfrom
feature/MOOSE-350/faceted-directory

Conversation

@GeoffDusome
Copy link
Copy Markdown
Contributor

What does this do/fix?

This pull request introduces a new integration with FacetWP, adding three new FacetWP-related blocks and their controllers, as well as a suite of enhancements to block registration, styling, and integration points. The changes include backend PHP logic for handling FacetWP blocks, improved asset enqueuing for block styles and scripts, and various integration hooks for customizing FacetWP's behavior and accessibility. Additionally, there are minor improvements to theme variables and icon sets.

FacetWP Integration and Blocks

  • Added three new blocks: tribe/facetwp-archive, tribe/facetwp-filter-bar, and tribe/facetwp-grid, each with dedicated controller classes (FacetWP_Archive_Controller, FacetWP_Filter_Bar_Controller, FacetWP_Grid_Controller) to handle block-specific logic and rendering. [1] [2] [3] [4]
  • Introduced a new FacetWP integration service with methods for retrieving facets, enhancing accessibility (adding IDs to controls), removing counts from certain facet types, registering custom facets (pagination, search, reset), and customizing pagination markup.
  • Registered new integration hooks in Integrations_Subscriber to expose facets to the block editor, modify FacetWP HTML output for accessibility and styling, and register custom facets and pagination markup.

Block Asset Registration and Loading

  • Refactored block asset enqueuing: public and editor styles/scripts are now enqueued using wp_enqueue_style/wp_enqueue_script with proper handles and versioning, and are loaded during the appropriate enqueue_block_assets action for both frontend and editor contexts. [1] [2] [3] [4]

Block Controller Enhancements

  • Updated the abstract block controller to support a context property, allowing block controllers to access block context values (needed for FacetWP filter bar positioning and logic). [1] [2]

Block Editor Template Improvements

  • Updated dynamic block editor template to use the block's metadata name for server-side rendering, ensuring correct registration and rendering of dynamic blocks. [1] [2]

Theme and Style Improvements

  • Added new icon variables for FacetWP UI elements and a new integration variables import for theme styling. [1] [2] [3]
  • Added a new box shadow variable and minor button style improvements for consistent UI appearance. [1] [2]

QA

Links to relevant issues

Screenshots/video:

Pull request checklist

  • I've added a changelog entry for these changes.
  • I've linked to a relevant Jira issue.
  • I've captured a screenshot or screencast of the changes and linked it above.

Copy link
Copy Markdown
Contributor

@spadilha spadilha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, @GeoffDusome 🌮🌮!! This is a big addition and very well implemented. I left a few comments and suggestions, plus one small thing that should be addressed, but nothing major. Thanks for the great work!

Comment on lines +141 to +164
.fs-option {
--checkbox-size: 24px;

/* top and bottom padding = half of the spacer-30 (helps each item have a larger click target)
left padding = spacer-20 + checkbox size + spacer-10 [label displays here] */
padding: calc(var(--spacer-30) / 2) var(--spacer-20) calc(var(--spacer-30) / 2) calc(var(--spacer-20) + var(--spacer-10) + var(--checkbox-size));

.fs-checkbox {
width: var(--checkbox-size);
height: var(--checkbox-size);
position: absolute;
left: var(--spacer-20);
top: 50%;
transform: translateY(-50%);
background: none;
border: 1px solid var(--color-neutral-30);
border-radius: 0;
background-color: var(--color-white);
transition: var(--transition);

i {
display: none;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Please add position: relative; to .fs-option, otherwise .fs-checkbox may overlap when the facet “Multi-select” is disabled. Even better might be to remove or hide the checkbox when it’s not multi-select, though the a11y impact would need to be tested.

Image

Comment on lines +48 to +60
<ToggleControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'Show All Posts', 'tribe' ) }
help={ __(
'If checked, all posts will be displayed in the grid. If unchecked, the number of posts displayed will be limited to the number set in the "Posts Per Page" setting.',
'tribe'
) }
checked={ showAllPosts }
onChange={ ( value ) =>
setAttributes( { showAllPosts: value } )
}
/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m a little concerned about exposing “Show All Posts” to editors if this sets posts_per_page to -1 under the hood. I’d lean toward removing this option and just letting editors choose a higher capped value for Posts Per Page instead, maybe up to 99. If we ever need truly unlimited behavior, that may be better kept as a developer controlled configuration rather than an editor facing setting.

If we do keep this option, I think we should hide the pagination toggle when showAllPosts is true, since those settings conflict logically.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the show all posts option and updated the posts per page setting to go up to 99. Agree that -1 can be configured based on the post type by a developer.

Comment on lines +296 to +303
<SortableFacet
key={ facet.slug }
facet={ facet }
onRemove={ handleRemoveFacet }
onDisplayLabelChange={
handleDisplayLabelChange
}
/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice SortableFacet component. The drag-and-drop behavior and inline label editing UX are very well done. 🤯 🌮

}

.b-facetwp-filter-bar__icon-btn:hover {
background: var(--wp-admin-theme-color, #007cba);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 This variable doesn’t exist. Also, the mobile filter flyout doesn’t appear to handle theme colors yet. I tested it with the group wrapper set to dark, and the labels become unreadable because its text color is the same as the background color.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--wp-admin-theme-color doesn't exist in Moose, but it does exist in the editor context, added by WP: https://p.tri.be/i/IGVshe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also fixed the issue with the flyout not correctly styling the text / button colors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants